package com.study.mynew.ui.Fragment;
import android.graphics.Color;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.google.android.material.internal.FlowLayout;
import com.study.mynew.R;


import java.util.ArrayList;
import java.util.List;

public class BottomCategoryFragment extends BottomSheetDialogFragment {

    private ImageButton back_btn;
    private TextView tvHint;
    private List<String> mTagsOn = new ArrayList<>();
    private List<String> mTagsOff = new ArrayList<>();
    private DataChangeListener mDataChangeListener;

    public interface DataChangeListener {
        void onDataChange(List<String> tagsOn, List<String> tagsOff);
    }
    public void setDataChangeListener(DataChangeListener dataChangeListener) {
        mDataChangeListener = dataChangeListener;
    }


    public static BottomCategoryFragment newInstance(List<String> tagsOn, List<String> tagsOff) {
        BottomCategoryFragment fragment = new BottomCategoryFragment();
        fragment.mTagsOn = tagsOn;
        fragment.mTagsOff = tagsOff;
        return fragment;
    }

//    @Override
//    public View onCreateView(LayoutInflater inflater, ViewGroup container,
//                             Bundle savedInstanceState) {
////        View v = inflater.inflate(R.layout.fragment_bottom_category, container, false);
////        back_btn = v.findViewById(R.id.back_btn);
////        tvHint = v.findViewById(R.id.tvHint);
//
//        return super;
//    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

//        CategoryAdapter categoryAdapterOn = new CategoryAdapter(mTagsOn);
//        CategoryAdapter categoryAdapterOff = new CategoryAdapter(mTagsOff);

        if (mTagsOff.size() == 0) {
            tvHint.setText("已全部添加到我的频道");
        } else {
            tvHint.setText("");
        }

        back_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    public void onDestroy() {
        mDataChangeListener.onDataChange(mTagsOn, mTagsOff);
        super.onDestroy();
    }
    private int getPixelsFromDp(float dpValue){
        return (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpValue, getResources().getDisplayMetrics());
    }



}